
import Api from '@/services/api.js'
const ODB_BASE = 'https://front.shencezixun.cn/api/front';
class Upload {
  constructor() {
    
  }

  // 上传
  upload = async ({ name = 'file', filePath, header = {} }) => {
    header = {
			//todo 如果有其他特殊处理或固定请求头参数 写在此处
			'utoken': 'zwkdev',
			...header,
		}

    return new Promise((resolve, reject) => {
      uni.uploadFile({
        url: ODB_BASE + Api.uploadImg1,
        name: 'file',
        filePath,
        header,
        success: res => {
          if (res.statusCode == 200) {
            resolve(JSON.parse(res.data));
          }else {
            reject(res);
          }
        },fail : fail => {
          reject(fail);
        }
      })
    })
  }
}
export default new Upload();